import time
import psutil

# 假设我们想监控PID为1234的进程
process = psutil.Process(pid=218456)

def show_process_thread_cpu():
    while True:
        # 获取并打印线程数量
        thread_count = process.num_threads()
        print(f"Process has {thread_count} threads.")

        # 获取并打印每个线程的信息
        for thread in process.threads():
            print(f"Thread ID: {thread.id}, User Time: {thread.user_time}, System Time: {thread.system_time}")
        
        time.sleep(1)

show_process_thread_cpu()